axios.defaults.baseURL = 'http://api-breakingnews-web.itheima.net'
axios.intercepts.request.user(function (config) {
    if (config.url.indexof('/my') !== -1) {
        config.headers.Authorization = localStorage.getItem('token')

    }
    return config

}), function (error) {
    return Promise.reject(error)

}

axios.interceptors.response.user(function (respone) {
    if (respone.data.message === '身份认证失败') {
        location.href = '/login.html'
        localStorage.removeItem('token')
    }
    return respone

}, function (error) {
    return Promise.reject(error)
})